package com.jieshuibao.controller;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.jieshuibao.common.config.Const;
import com.jieshuibao.common.res.BaseRes;
import com.jieshuibao.model.db.CmsArticle;
import com.jieshuibao.model.db.Company;
import com.jieshuibao.model.db.Invoice;
import com.jieshuibao.model.db.PurchaseOrder;
import com.jieshuibao.model.db.PurchaseOrderExample;
import com.jieshuibao.model.db.PurchaseOrderExample.Criteria;
import com.jieshuibao.model.db.RedEnvelopes;
import com.jieshuibao.model.db.User;
import com.jieshuibao.model.db.VipCard;
import com.jieshuibao.model.db.VipCardExample;
import com.jieshuibao.model.db.Withdraw;
import com.jieshuibao.model.db.WithdrawExample;
import com.jieshuibao.model.domain.AddAdmireResponse;
import com.jieshuibao.model.domain.AddInvoiceRequest;
import com.jieshuibao.model.domain.AllCardResponse;
import com.jieshuibao.model.domain.AllPurchaseResponse;
import com.jieshuibao.model.domain.BuyCardRequest;
import com.jieshuibao.model.domain.BuyCardResponse;
import com.jieshuibao.model.domain.CodeDesResponse;
import com.jieshuibao.model.domain.CookieUser;
import com.jieshuibao.model.domain.EditInvoiceResponse;
import com.jieshuibao.model.domain.GiveUserRedEncelopesResponse;
import com.jieshuibao.model.domain.PagePhone;
import com.jieshuibao.model.domain.PageRequest;
import com.jieshuibao.model.domain.QuestionRequest;
import com.jieshuibao.model.domain.RedEnvelopesRecordingResponse;
import com.jieshuibao.model.domain.RedEnvelopesRequest;
import com.jieshuibao.model.domain.SendCompanyEnvelopesRequest;
import com.jieshuibao.model.domain.SendRedResponse;
import com.jieshuibao.model.domain.UserSendEnvelopesRequest;
import com.jieshuibao.model.domain.UserSendEnvelopesResponse;
import com.jieshuibao.model.domain.WithdawRecordinResponse;
import com.jieshuibao.service.CmsArticleService;
import com.jieshuibao.service.CompanyService;
import com.jieshuibao.service.InvoiceService;
import com.jieshuibao.service.PayVipBanlanceService;
import com.jieshuibao.service.PurchaseOrderService;
import com.jieshuibao.service.RedEnvelopesService;
import com.jieshuibao.service.RedisService;
import com.jieshuibao.service.SmsSendService;
import com.jieshuibao.service.UserCounselorService;
import com.jieshuibao.service.UserService;
import com.jieshuibao.service.VipCardService;
import com.jieshuibao.service.WeiXinPayService;
import com.jieshuibao.service.WithdrawService;
import com.jieshuibao.util.PayTypeUtil;
import com.jieshuibao.util.StringUtils;
import com.jieshuibao.util.UUIDGenerator;
import com.jieshuibao.wx.po.WxAppPayReq;
import com.jieshuibao.wx.po.WxAppPayRes;
import com.jieshuibao.wx.po.WxJsPayReq;
import com.jieshuibao.wx.po.WxjsPayRes;
import com.jieshuibao.wx.util.PayCommonUtil;

@Controller
@RequestMapping(value = "/pay")
public class PaymentController {
	private static final Logger logger = LoggerFactory
			.getLogger("PaymentController.class");

	private static final ObjectMapper mapper = new ObjectMapper();
	//private static final String appId = "8aaf07086619653001661b1865b301fa";
	@Resource
	private UserService userService;
	@Resource
	private RedisService redisService;
	@Resource
	private UserCounselorService userCounselorService;
	@Resource
	private RedEnvelopesService redEnvelopesService;
	@Resource
	private InvoiceService invoiceService;
	@Resource
	private VipCardService vipCardService;
	@Resource
	private PurchaseOrderService purchaseOrderService;
	@Resource
	private WeiXinPayService weiXinPayService;
	@Resource
	private CmsArticleService cmsArticleService;
	@Resource
	private WithdrawService withdrawService;
	@Resource
	private CompanyService companyService;
	@Resource
	private SmsSendService smsSendService;

	@Resource
	private PayVipBanlanceService payVipBanlanceService;
	@Value("${producttype.vip}")
	private String producttypeVip;
	@Value("${producttype.redbag}")
	private String producttypeRedbag;
	@Value("${card.images.url}")
	private String cardImagesUrl;

	// 领取红包接口
	@RequestMapping(value = "/receiveRed", method = RequestMethod.POST)
	@ResponseBody
	public Object receiveRed(HttpServletRequest request,
			@RequestBody RedEnvelopesRequest redEnvelopesRequest) {
		CodeDesResponse redEnvelopesResponse = new CodeDesResponse();

		try {
			logger.info("接收：" + mapper.writeValueAsString(redEnvelopesRequest));

				CookieUser cookieUser = (CookieUser)request.getAttribute("cookieUser");
				if (cookieUser != null) {

					String phoneNumber = cookieUser.getPhoneNumber();
					if (phoneNumber != null) {
						User user2 = userService
								.getUserByPhoneNumber(phoneNumber);
						Double balance = user2.getBalance();
						Double money = redEnvelopesRequest.getMoney();
						String questionUuid = redEnvelopesRequest
								.getQuestionUuid();
						if (questionUuid != null && !questionUuid.equals("")) {
							User user = new User();
							user.setPhoneNumber(phoneNumber);
							user.setBalance(balance + money);
							RedEnvelopes redEnvelopes = redEnvelopesService
									.getRedEnvelopes(questionUuid, phoneNumber);
							
							if (redEnvelopes != null) {
								String redStatus = redEnvelopes.getRedStatus();
								if(redStatus.equals("1")){
									RedEnvelopes redEnvelopes2 = new RedEnvelopes();
									redEnvelopes2.setUuid(redEnvelopes.getUuid());
									redEnvelopes2.setMoney(money);
									redEnvelopes2.setReceiveDate(new Date());
									redEnvelopes2.setRedStatus(PayCommonUtil.PAYSUCCESS_STATUS);
									userCounselorService.updateAndAddRedEnvelopes(user, redEnvelopes2);
									redEnvelopesResponse.setCode("1");
									redEnvelopesResponse.setDes("领取成功，已存余额");
								}else {
									redEnvelopesResponse.setCode("3");
									redEnvelopesResponse.setDes("红包已领");
								}
							} else {
								// 领取失败
								redEnvelopesResponse.setCode("3");
								redEnvelopesResponse.setDes("数据格式错误!");
							}
						} else {
							// 数据格式错误
							redEnvelopesResponse.setCode("3");
							redEnvelopesResponse.setDes("数据格式错误");
						}

					} else {
						//
						// 重新登录
						redEnvelopesResponse.setCode("2");
						redEnvelopesResponse.setDes("重新登录");
					}
				} else {
					// 重新登录
					redEnvelopesResponse.setCode("2");
					redEnvelopesResponse.setDes("重新登录");
				}
			
			logger.info("返回：" + mapper.writeValueAsString(redEnvelopesResponse));
		} catch (Exception e) {
			e.printStackTrace();
			redEnvelopesResponse.setCode("0");
			redEnvelopesResponse.setDes("系统繁忙");
		}
		return redEnvelopesResponse;
	}

	// 提交发票接口

	@RequestMapping(value = "/addInvoice", method = RequestMethod.POST)
	@ResponseBody
	public Object addInvoice(HttpServletRequest request,
			@RequestBody AddInvoiceRequest addInvoiceRequest) {
		AddAdmireResponse addInvoiceResponse = new AddAdmireResponse();

		try {
			logger.info("接收：" + mapper.writeValueAsString(addInvoiceRequest));

				CookieUser cookieUser = (CookieUser)request.getAttribute("cookieUser");
				if (cookieUser != null) {
					String phoneNumber = cookieUser.getPhoneNumber();
					String address = addInvoiceRequest.getAddress();
					String companyName = addInvoiceRequest.getCompanyName();
					String email = addInvoiceRequest.getEmail();
					String receiverName = addInvoiceRequest.getReceiverName();
					String receiverPhoneNum = addInvoiceRequest
							.getReceiverPhoneNum();
					String taxNum = addInvoiceRequest.getTaxNum();
					String taxType = addInvoiceRequest.getTaxType();
					String accountBank = addInvoiceRequest.getAccountBank();
					String accountNumber = addInvoiceRequest.getAccountNumber();
					String companyTell = addInvoiceRequest.getCompanyTell();
					String companyAddress = addInvoiceRequest.getCompanyAddress();
					boolean ifSpecial = false;
					if("增值税专用发票".equals(taxType)){
						ifSpecial = true;
					}
					Invoice invoice = invoiceService
							.getInvocieByPhoneNum(phoneNumber);
					PurchaseOrder purchaseOrder=null;
					String orderUuid = addInvoiceRequest.getUuid();
					if(StringUtils.isNotBlank(orderUuid)){
						PurchaseOrder purchaseOrder2 = purchaseOrderService.getPurchaseOrderByUuid(orderUuid);
						if(purchaseOrder2!=null){
							Integer invoiceStatus = purchaseOrder2.getInvoiceStatus();
							if (invoiceStatus!=null&&invoiceStatus>=0) {
								addInvoiceResponse.setCode(BaseRes.ERRORPARAM_CODE);
								addInvoiceResponse.setDes("已开过发票！");
								return addInvoiceResponse;
							}
							purchaseOrder=new PurchaseOrder();
							purchaseOrder.setInvoiceStatus(PayTypeUtil.INVOICETYPE_YES);
							purchaseOrder.setUuid(orderUuid);
						}
					}
					if(ifSpecial){
						if(StringUtils.isBlank(accountBank) || StringUtils.isBlank(accountNumber)
							|| StringUtils.isBlank(companyTell) || StringUtils.isBlank(companyAddress)){
							// 专用发票时，开户银行，银行账号，公司电话，公司地址不能为空
							addInvoiceResponse.setCode("3");
							addInvoiceResponse.setDes("专用发票的开户银行，银行账号，公司电话，公司地址不能为空");
							return addInvoiceResponse;
						}
					}
					if (invoice == null) {
						// 第一次填写发票信息
						if (/*StringUtils.isNotBlank(address) && */StringUtils.isNotBlank(companyName)
								/*&& StringUtils.isNotBlank(receiverName)*/ && StringUtils.isNotBlank(receiverPhoneNum)
								&& StringUtils.isNotBlank(taxNum) && StringUtils.isNotBlank(taxType) && StringUtils.isNotBlank(email)){
							if (!StringUtils.isTaxNum(taxNum)) {
								addInvoiceResponse.setCode("3");
								addInvoiceResponse.setDes("纳税人识别号错误！");
								return addInvoiceResponse;
							}

							if (StringUtils.isMobile(receiverPhoneNum)) {
								String uuid = UUIDGenerator.getUUID();
								Invoice invoice1 = new Invoice();
								invoice1.setAddress(address);
								invoice1.setCompanyName(companyName);
								invoice1.setReceiverName(receiverName);
								invoice1.setReceiverPhoneNum(receiverPhoneNum);
								invoice1.setUserPhoneNum(phoneNumber);
								invoice1.setUuid(uuid);
								invoice1.setTaxNum(taxNum);
								invoice1.setTaxType(taxType);
								invoice1.setAccountBank(accountBank);
								invoice1.setAccountNumber(accountNumber);
								invoice1.setCompanyTell(companyTell);
								invoice1.setCompanyAddress(companyAddress);
								invoice1.setAccountBank(accountBank);
								invoice1.setAccountNumber(accountNumber);
								invoice1.setCompanyTell(companyTell);
								invoice1.setCompanyAddress(companyAddress);
								
								if (email != null && !email.equals("")) {
									if (StringUtils.checkEmail(email)) {
										invoice1.setEmail(email);
									} else {
										// 邮箱格式错误
										addInvoiceResponse.setCode("3");
										addInvoiceResponse.setDes("邮箱格式错误");
										return addInvoiceResponse;
									}
								}
								purchaseOrderService.addAndUpdateInvoicePurchase(invoice1, purchaseOrder);
								addInvoiceResponse.setCode("1");
								addInvoiceResponse.setDes("填写发票成功");

							} else {
								// 手机号填写错误
								addInvoiceResponse.setCode("3");
								addInvoiceResponse.setDes("手机号填写错误");
								return addInvoiceResponse;
							}

						} else {
							// 收件人姓名，联系方式，地址，手机号，公司名不能为空
							addInvoiceResponse.setCode("3");
//							addInvoiceResponse.setDes("收件人姓名，联系方式，地址，公司名不能为空");
							addInvoiceResponse.setDes("公司抬头、公司税号、开票人手机号和邮箱不能为空");
						}
					} else {
						// 已经填过发票
						if (address != null && !address.equals("")) {

							invoice.setAddress(address);
						} 
						
						if (companyName != null && !companyName.equals("")) {
							invoice.setCompanyName(companyName);
						}
						if (email != null && !email.equals("")) {
							if (StringUtils.checkEmail(email)) {
								invoice.setEmail(email);
							}
						}
						if (receiverName != null && !receiverName.equals("")) {
							invoice.setReceiverName(receiverName);
						}
						if (receiverPhoneNum != null
								&& !receiverPhoneNum.equals("")) {
							
						if(StringUtils.isMobile(receiverPhoneNum)){
							invoice.setReceiverPhoneNum(receiverPhoneNum);
							}else {
								addInvoiceResponse.setCode("3");
								addInvoiceResponse.setDes("手机格式错误");
								return addInvoiceResponse;
							}
						}
						if (StringUtils.isNotBlank(taxType)) {
							invoice.setTaxType(taxType);
						}
						if (StringUtils.isNotBlank(taxNum)) {
							if (StringUtils.isTaxNum(taxNum)) {
								invoice.setTaxNum(taxNum);
							}else {
								addInvoiceResponse.setCode("3");
								addInvoiceResponse.setDes("纳税人识别号错误！");
								return addInvoiceResponse;
							}
							
						}
						invoice.setAccountBank(accountBank);
						invoice.setAccountNumber(accountNumber);
						invoice.setCompanyTell(companyTell);
						invoice.setCompanyAddress(companyAddress);
						purchaseOrderService.UpdateInvoicePurchase(invoice, purchaseOrder);
						addInvoiceResponse.setCode("1");
						addInvoiceResponse.setDes("修改成功");

					}

				} else {
					// 重新登录
					addInvoiceResponse.setCode("2");
					addInvoiceResponse.setDes("重新登录");
				}
			
			logger.info("返回：" + mapper.writeValueAsString(addInvoiceResponse));
		} catch (Exception e) {
			e.printStackTrace();
			addInvoiceResponse.setCode("0");
			addInvoiceResponse.setDes("系统繁忙");
		}
		return addInvoiceResponse;
	}

	// 判断是否开过发票
	@RequestMapping(value = "/isInvoice", method = RequestMethod.POST)
	@ResponseBody
	public Object isAddInvoice(HttpServletRequest request) {
		AddAdmireResponse addInvoiceResponse = new AddAdmireResponse();

		try {
			
				CookieUser cookieUser = (CookieUser)request.getAttribute("cookieUser");
				if (cookieUser != null) {
					String phoneNumber = cookieUser.getPhoneNumber();
					Invoice invocie = invoiceService
							.getInvocieByPhoneNum(phoneNumber);
					if (invocie != null) {
						addInvoiceResponse.setCode("1");
						addInvoiceResponse.setDes("已经填过发票信息");
					} else {
						addInvoiceResponse.setCode("4");
						addInvoiceResponse.setDes("还没有填过发票信息，请先填发票信息");
					}

				} else {
					// 重新登录
					addInvoiceResponse.setCode("2");
					addInvoiceResponse.setDes("重新登录");
				}
			
			logger.info("返回：" + mapper.writeValueAsString(addInvoiceResponse));
		} catch (Exception e) {
			e.printStackTrace();
			addInvoiceResponse.setCode("0");
			addInvoiceResponse.setDes("系统繁忙");
		}
		return addInvoiceResponse;
	}

	// 会员卡列表接口
	@RequestMapping(value = "/card", method = RequestMethod.POST)
	@ResponseBody
	public Object allCard(HttpServletRequest request) {
		AllCardResponse allCardResponse = new AllCardResponse();

		try {
			
				CookieUser cookieUser = (CookieUser)request.getAttribute("cookieUser");
				if (cookieUser != null) {
					
					String phoneNumber = cookieUser.getPhoneNumber();
					PurchaseOrderExample example2 = new PurchaseOrderExample();
					Criteria criteria = example2.createCriteria();
					criteria.andProductTypeEqualTo("0");
					criteria.andPhoneNumEqualTo(phoneNumber);
					criteria.andPaymentStatusEqualTo(PayCommonUtil.PAYSUCCESS_STATUS);
					int i = purchaseOrderService.countPurchaseOrder(example2);
					VipCardExample example = new VipCardExample();
					example.setOrderByClause("cardNum desc");
					if(i>0){
						com.jieshuibao.model.db.VipCardExample.Criteria criteria2 = example.createCriteria();
						criteria2.andCardStyleNotEqualTo("0");
					}
					List<VipCard> vipCard = vipCardService.getVipCard(example);
					allCardResponse.setVipCards(vipCard);
					allCardResponse.setCardImageUrl(cardImagesUrl);
					allCardResponse.setCode("1");

				} else {
					// 重新登录
					allCardResponse.setCode("2");
					allCardResponse.setDes("重新登录");
				}
			
			logger.info("返回：" + mapper.writeValueAsString(allCardResponse));
		} catch (Exception e) {
			e.printStackTrace();
			allCardResponse.setCode("0");
			allCardResponse.setDes("系统繁忙");
		}
		return allCardResponse;
	}

	// 发票记录接口

	@RequestMapping(value = "/purchaseOrder", method = RequestMethod.POST)
	@ResponseBody
	public Object purchasOrder(HttpServletRequest request,
			@RequestBody QuestionRequest allPurchaseRequest) {
		AllPurchaseResponse allPurchaseResponse = new AllPurchaseResponse();

		try {
			
				CookieUser cookieUser = (CookieUser)request.getAttribute("cookieUser");
				if (cookieUser != null) {
					String phoneNumber = cookieUser.getPhoneNumber();
					int sinceId = allPurchaseRequest.getSinceId();
					int maxId = allPurchaseRequest.getMaxId();

					if (sinceId <= 0) {
						sinceId = 1;
					}
					if (maxId <= 0 || maxId < sinceId) {
						maxId = sinceId;
					}
					PagePhone pagePhone = new PagePhone();
					pagePhone.setPageIndex(sinceId - 1);
					pagePhone.setPageSize(maxId - sinceId + 1);
					pagePhone.setPhoneNum(phoneNumber);
					List<PurchaseOrder> purchaseOrders = purchaseOrderService
							.getPurchaseOrdersByPhoneNum(pagePhone);
					
					for (PurchaseOrder purchaseOrder : purchaseOrders) {
						String productType = purchaseOrder.getProductType();
						if(productType!=null&&!productType.equals("")){
							if(productType.equals(PayTypeUtil.PRODUCTTYPE_VIPCARD)){
								purchaseOrder.setProductType(PayTypeUtil.PRODUCTTYPESTRING_VIPCARD);
							}else if(productType.equals(PayTypeUtil.PRODUCTTYPE_EXPERIENCE)){
								purchaseOrder.setProductType(PayTypeUtil.PRODUCTTYPESTRING_EXPERIENCE);
							}	
						}else {
							purchaseOrder.setProductType(PayTypeUtil.PRODUCTTYPESTRING_VIPCARD);
						}
						
					}
					allPurchaseResponse.setCode("1");
					allPurchaseResponse.setPurchaseOrders(purchaseOrders);
					allPurchaseResponse.setMaxId(sinceId
							+ purchaseOrders.size() - 1);
					allPurchaseResponse.setSinceId(sinceId);
					allPurchaseResponse.setRows(purchaseOrders.size());

				} else {
					// 重新登录
					allPurchaseResponse.setCode("2");
					allPurchaseResponse.setDes("重新登录");
				}
			
			logger.info("返回：" + mapper.writeValueAsString(allPurchaseResponse));
		} catch (Exception e) {
			e.printStackTrace();
			allPurchaseResponse.setCode("0");
			allPurchaseResponse.setDes("系统繁忙");
		}
		return allPurchaseResponse;
	}

	// 编辑发票接口
	@RequestMapping(value = "/editInvoice", method = RequestMethod.POST)
	@ResponseBody
	public Object editInvoice(HttpServletRequest request) {
		EditInvoiceResponse editInvoiceResponse = new EditInvoiceResponse();

		try {
			
				CookieUser cookieUser = (CookieUser)request.getAttribute("cookieUser");
				if (cookieUser != null) {
					String phoneNumber = cookieUser.getPhoneNumber();
					if (phoneNumber != null) {
						Invoice invoice = invoiceService
								.getInvocieByPhoneNum(phoneNumber);
						editInvoiceResponse.setCode("1");
						editInvoiceResponse.setInvoice(invoice);
					}
				} else {
					// 重新登录
					editInvoiceResponse.setCode("2");
					editInvoiceResponse.setDes("重新登录");
				}
			
			logger.info("返回：" + mapper.writeValueAsString(editInvoiceResponse));
		} catch (Exception e) {
			e.printStackTrace();
			editInvoiceResponse.setCode("0");
			editInvoiceResponse.setDes("系统繁忙");
		}
		return editInvoiceResponse;
	}

	// 会员卡购买接口
	@RequestMapping(value = "/buyCard", method = RequestMethod.POST)
	@ResponseBody
	public Object membershipCard(HttpServletRequest request,
			@RequestBody BuyCardRequest buyCardRequest) {
		BuyCardResponse buyCardResponse = new BuyCardResponse();

		try {
			
			logger.info("接收：" + mapper.writeValueAsString(buyCardRequest));
		
				CookieUser cookieUser = (CookieUser)request.getAttribute("cookieUser");
				if (cookieUser != null) {
					String phoneNumber = cookieUser.getPhoneNumber();
					double currentPrice = buyCardRequest.getCurrentPrice();
					double originalPrice = buyCardRequest.getOriginalPrice();
					String invoiceStatus = buyCardRequest.getInvoiceStatus();
					String cardStyle = buyCardRequest.getCardStyle();
					String uuid2 = buyCardRequest.getUuid();
					if (StringUtils.isBlank(uuid2)) {
						buyCardResponse.setCode(BaseRes.ERRORPARAM_CODE);
						buyCardResponse.setDes(BaseRes.ERRORPARAM_DES);
						return buyCardResponse;
					}
					VipCard vipCard = vipCardService.getVipCardByUuid(uuid2);
					if (vipCard==null) {
						buyCardResponse.setCode(BaseRes.ERRORPARAM_CODE);
						buyCardResponse.setDes(BaseRes.ERRORPARAM_DES);
						return buyCardResponse;
					}
					String cardStyle2 = vipCard.getCardStyle();
					//String cardType = vipCard.getCardType();
					Integer currentPrice2 = vipCard.getCurrentPrice();
					Integer originalPrice2 = vipCard.getOriginalPrice();
					if (currentPrice2!=currentPrice||originalPrice!=originalPrice2) {
						buyCardResponse.setCode(BaseRes.ERRORPARAM_CODE);
						buyCardResponse.setDes("非法操作，数据异常");
						return buyCardResponse;
					}
					if (StringUtils.isBlank(cardStyle)) {
						buyCardResponse.setCode(BaseRes.ERRORPARAM_CODE);
						buyCardResponse.setDes(BaseRes.ERRORPARAM_DES);
						return buyCardResponse;
					}
					if (StringUtils.isBlank(cardStyle2)) {
						buyCardResponse.setCode(BaseRes.ERRORPARAM_CODE);
						buyCardResponse.setDes("数据错误！");
						return buyCardResponse;
					}
					if (!cardStyle2.equals(cardStyle)) {
						buyCardResponse.setCode(BaseRes.ERRORPARAM_CODE);
						buyCardResponse.setDes(BaseRes.ERRORPARAM_DES);
						return buyCardResponse;
					}
					PurchaseOrder purchaseOrder = new PurchaseOrder();
					if(cardStyle2.equals(PayTypeUtil.PRODUCTTYPE_EXPERIENCE)){//购买的是体验卡
						PurchaseOrderExample example2 = new PurchaseOrderExample();
						Criteria criteria = example2.createCriteria();
						criteria.andProductTypeEqualTo(PayTypeUtil.PRODUCTTYPE_EXPERIENCE);
						criteria.andPhoneNumEqualTo(phoneNumber);
						int i = purchaseOrderService.countPurchaseOrder(example2);
						if(i>0){
							//已经购买过
							buyCardResponse.setCode(BaseRes.ERRORPARAM_CODE);
							buyCardResponse.setDes("你已经购买过体验卡 ");
							return buyCardResponse;
						}else {
							//第一次购买体验卡
							purchaseOrder.setProductType(PayTypeUtil.PRODUCTTYPE_EXPERIENCE);
						}
					}else {
						//其他卡
						purchaseOrder.setProductType(PayTypeUtil.PRODUCTTYPE_VIPCARD);
						
					}
					String payType = buyCardRequest.getPayType();
					if (StringUtils.isNotBlank(payType)&&StringUtils.isNotBlank(invoiceStatus)) {

						
						User user = userService
								.getUserByPhoneNumber(phoneNumber);
						Integer companyRole = user.getCompanyRole();
						if (companyRole != 2) {
							User user2 = new User();
							user2.setPhoneNumber(phoneNumber);
							String uuid = UUIDGenerator.getUUID();
							purchaseOrder.setUuid(uuid);
							if (invoiceStatus.equals("0")) {
								//发票的状态-1
								purchaseOrder.setInvoiceStatus(PayTypeUtil.INVOICETYPE_NO);
							} else if(invoiceStatus.equals("1")){
								purchaseOrder.setInvoiceStatus(PayTypeUtil.INVOICETYPE_YES);
							}else {
								buyCardResponse.setCode("3");
								buyCardResponse.setDes("请选择是否开发票");
								return buyCardResponse;
							}
							
							Date date = new Date();
							purchaseOrder.setPaymentDate(date);
							purchaseOrder.setPhoneNum(phoneNumber);

							if (payType.equals("weixin")) {
								purchaseOrder.setPaymentStatus(PayCommonUtil.PAYPENDING_STATUS);
								purchaseOrder.setPayType(PayTypeUtil.PAYTYPE_WEIXIN);
								purchaseOrder.setCurrentPrice(currentPrice);
								purchaseOrder.setOriginalPrice(originalPrice);
								purchaseOrderService.addPurchaseOrder(purchaseOrder);
								int source = buyCardRequest.getSource();
								String code = buyCardRequest.getCode();
								if(source==1){
									WxJsPayReq req=new WxJsPayReq();
									req.setCode(code);
									req.setPhone(phoneNumber);
									req.setUnitPrice(currentPrice);
									req.setRealPrice(originalPrice);
									req.setProductName("购买顾问卡");
									req.setProductType(Const.VIP);
									req.setProductId(uuid);
									WxjsPayRes jssdPayRes=(WxjsPayRes)weiXinPayService.jSSDKPayInfo(req, request);
									return jssdPayRes;
								}else {
									WxAppPayReq wxAppPayReq = new WxAppPayReq();
									
									wxAppPayReq.setAmount(1);
									wxAppPayReq.setPhone(phoneNumber);
									wxAppPayReq.setProductId(uuid);
									wxAppPayReq.setProductName("购买顾问卡");
									wxAppPayReq.setUnitPrice(currentPrice);
									wxAppPayReq.setRealPrice(originalPrice);
									wxAppPayReq.setProductType(producttypeVip);
									
									WxAppPayRes appPay = (WxAppPayRes) weiXinPayService
											.appPay(wxAppPayReq, request);
									
									return appPay;
								}
							} else if (payType.equals("balance")) {
								Double balance = user.getBalance();
								if (currentPrice <= balance) {
									user2.setBalance(-currentPrice);
									purchaseOrder
											.setPayType(PayTypeUtil.PAYTYPE_BALANCE);
									purchaseOrder.setPaymentStatus(PayCommonUtil.PAYSUCCESS_STATUS);
									purchaseOrder.setCurrentPrice((double)currentPrice2);
									purchaseOrder
											.setOriginalPrice((double)originalPrice2);
									String companyUuid = user.getCompanyUuid();

									if (companyUuid != null && companyRole == 1) {
										Company company = companyService
												.getCompanyByUuid(companyUuid);
										if (company != null) {
											Double businessBalance = company
													.getBusinessBalance();
											company.setBusinessBalance(businessBalance
													+ originalPrice);
											purchaseOrderService.updateUserAndCompanyAndPurchase(purchaseOrder, user2, company);
											buyCardResponse.setCode("1");
											buyCardResponse.setDes("购买成功");

										} else {
											// 数据格式错误
											buyCardResponse.setCode("3");
											buyCardResponse.setDes("数据格式错误");
										}
									} else if (companyRole == 0) {
										user2.setVipBalance((double)originalPrice2);
										purchaseOrderService.updateUserAndCompanyAndPurchase(purchaseOrder, user2, null);
										buyCardResponse.setCode("1");
										buyCardResponse.setDes("购买成功");

									} else {
										// 数据格式错误
										buyCardResponse.setCode("3");
										buyCardResponse.setDes("数据格式错误");

									}

								} else {
									// 余额不足
									buyCardResponse.setCode("4");
									buyCardResponse.setDes("余额不足");
								}
							} else {
								// 请选择支付方式
								buyCardResponse.setCode("4");
								buyCardResponse.setDes("请选择支付方式");
							}

						} else {
							// 请让管理员购买
							buyCardResponse.setCode("3");
							buyCardResponse.setDes("你是企业用户，请让管理员购买");
						}
					} else {
						// 数据格式错去
						buyCardResponse.setCode("3");
						buyCardResponse.setDes("数据格式错误");
					}

				} else {
					// 重新登录
					buyCardResponse.setCode("2");
					buyCardResponse.setDes("重新登录");
				}
		
			logger.info("返回：" + mapper.writeValueAsString(buyCardResponse));
		} catch (Exception e) {
			e.printStackTrace();
			buyCardResponse.setCode("0");
			buyCardResponse.setDes("系统繁忙");
		}
		return buyCardResponse;
	}

	/**
	 * 公司发红包接口
	 * @param request
	 * @param sendCompanyEnvelopesRequest
	 * @return
	 */
	@RequestMapping(value = "/companyEnveloeps", method = RequestMethod.POST)
	@ResponseBody
	public Object sendEnvelopes(HttpServletRequest request,
			@RequestBody SendCompanyEnvelopesRequest sendCompanyEnvelopesRequest) {
		GiveUserRedEncelopesResponse giveUserRedEncelopesResponse = new GiveUserRedEncelopesResponse();

		try {
			logger.info("接收："
					+ mapper.writeValueAsString(sendCompanyEnvelopesRequest));

				CookieUser cookieUser = (CookieUser)request.getAttribute("cookieUser");
				if (cookieUser != null) {
					String phoneNumber = cookieUser.getPhoneNumber();
					String questionUuid = sendCompanyEnvelopesRequest
							.getQuestionUuid();
					String redType = sendCompanyEnvelopesRequest.getRedType();
					SendRedResponse sendRedResponse = (SendRedResponse) redEnvelopesService
							.addSendRedEnvelopes(questionUuid, phoneNumber,redType);
					boolean send = sendRedResponse.isSend();
					if (send) {
						double money = sendRedResponse.getMoney();
						giveUserRedEncelopesResponse.setCode("1");
						giveUserRedEncelopesResponse.setMoney(money);
						giveUserRedEncelopesResponse.setDes("亲，已给你发送一个红包");
					} else {
						giveUserRedEncelopesResponse.setCode("1");
						giveUserRedEncelopesResponse.setMoney(0.0);
						giveUserRedEncelopesResponse
								.setDes("亲，你已领过红包了，这次就不给你发了");
					}

				} else {
					// 重新登录
					giveUserRedEncelopesResponse.setCode("2");
					giveUserRedEncelopesResponse.setDes("重新登录");
				}
			
			logger.info("返回："
					+ mapper.writeValueAsString(giveUserRedEncelopesResponse));
		} catch (Exception e) {
			e.printStackTrace();
			giveUserRedEncelopesResponse.setCode("0");
			giveUserRedEncelopesResponse.setDes("系统繁忙");
		}
		return giveUserRedEncelopesResponse;
	}

	// 用户发红包接口
	@RequestMapping(value = "/userEnvelopes", method = RequestMethod.POST)
	@ResponseBody
	public Object userSendEnvelopes(HttpServletRequest request,
			@RequestBody UserSendEnvelopesRequest userSendEnvelopesRequest) {
		UserSendEnvelopesResponse userSendEnvelopesResponse = new UserSendEnvelopesResponse();

		try {
			logger.info("接收："
					+ mapper.writeValueAsString(userSendEnvelopesRequest));

				CookieUser cookieUser = (CookieUser)request.getAttribute("cookieUser");
				if (cookieUser != null) {
					String articleId = userSendEnvelopesRequest.getArticleId();
					String payType = userSendEnvelopesRequest.getPayType();
					Double money = userSendEnvelopesRequest.getMoney();
					String phoneNumber = cookieUser.getPhoneNumber();

					if (phoneNumber != null) {
						CmsArticle article = cmsArticleService
								.getCmsArticleById(articleId);
						if (article != null) {
							if (articleId != null && !articleId.equals("")
									&& payType != null && !payType.equals("")) {
								User user = userService.getUserByPhoneNumber(phoneNumber);
								if (user != null) {
									//Double balance = user.getBalance();
									// Double vipBalance = user.getVipBalance();
									String phoneNum = article.getCreatBy();

									if (phoneNum != null
											&& !phoneNum.equals(phoneNumber)) {
										User user4 = userService
												.getUserByPhoneNumber(phoneNum);
										if (user4 != null) {
											User user2 = new User();
											User user3 = new User();
											Double balance2 = user4
													.getBalance();
											user3.setPhoneNumber(phoneNum);
											user2.setPhoneNumber(phoneNumber);
											user3.setBalance(balance2 + money);
											RedEnvelopes redEnvelopes = new RedEnvelopes();
											String uuid = UUIDGenerator
													.getUUID();
											redEnvelopes.setMoney(money);
											redEnvelopes
													.setQuestionUuid(articleId);
											redEnvelopes
													.setRedStatus(PayCommonUtil.PAYSUCCESS_STATUS);
											redEnvelopes
													.setRedType(PayTypeUtil.REDENVELPES_REWARD);
											Date date = new Date();
											
											redEnvelopes
													.setSendDate(date);
											redEnvelopes.setReceiveDate(date);
											redEnvelopes
													.setSendPhoneNum(phoneNumber);
											redEnvelopes
													.setUserPhoneNum(phoneNum);
											redEnvelopes.setUuid(uuid);
											String realName = user.getRealName();
											if(realName==null||realName.equals("")){
												realName=phoneNumber;
											}
											//String[] str={user4.getRealName(),realName,""+money+""};
											
											
											if (payType.equals("balance")) {
												/*if (money <= balance) {
													user2.setBalance(balance
															- money);
													// 需要加推送让用户知道别人给他发了一个红包
													if(StringUtils.isMobile(phoneNum)){
														smsSendService.sendNotify(appId,phoneNum, Const.SCENE_REDBAG_REWARD, str);
													}
													
													redEnvelopes.setPayType(PayTypeUtil.PAYTYPE_BALANCE);

													redEnvelopesService.updateUserAndAddRedEnvelopes(user3, user2, redEnvelopes);
													userSendEnvelopesResponse
															.setCode("1");
													userSendEnvelopesResponse
															.setDes("打赏成功");
												} else {
													// 余额不足
													userSendEnvelopesResponse
															.setCode("4");
													userSendEnvelopesResponse
															.setDes("余额不足");

												}*/
												userSendEnvelopesResponse.setCode("3");
												userSendEnvelopesResponse.setDes("请选择微信打赏");
												return userSendEnvelopesResponse;
											} else if (payType.equals("VipBalance")) {/*
												int i =payVipBanlanceService.updateUserAndCompanyRedEnvelopes(user, user4, redEnvelopes, money);
												if (i == 1 || i == 2) {
													userSendEnvelopesResponse
															.setCode("1");
													userSendEnvelopesResponse
															.setDes("发送成功");
													if(StringUtils.isMobile(phoneNum)){
														smsSendService.sendNotify(appId,phoneNum, Const.SCENE_REDBAG_REWARD, str);
													}
													return userSendEnvelopesResponse;
												} else if (i == 3) {
													//
													userSendEnvelopesResponse
															.setCode("3");
													userSendEnvelopesResponse
															.setDes("数据格式错误！");
													return userSendEnvelopesResponse;
												} else if (i == 4) {
													userSendEnvelopesResponse
															.setCode("4");
													userSendEnvelopesResponse
															.setDes("会员卡余额不足");
													return userSendEnvelopesResponse;
												} else if (i == 0) {
													userSendEnvelopesResponse
															.setCode("0");
													userSendEnvelopesResponse
															.setDes("系统繁忙");
													return userSendEnvelopesResponse;
												}

												*/
												userSendEnvelopesResponse.setCode("3");
												userSendEnvelopesResponse.setDes("不能用会员卡打赏");
												return userSendEnvelopesResponse;
										
												
											
											} else if (payType
													.equals("weixin")) {
												redEnvelopes
														.setRedStatus(PayCommonUtil.PAYPENDING_STATUS);
												redEnvelopes.setPayType(PayTypeUtil.PAYTYPE_WEIXIN);
												redEnvelopesService
														.addRedEnvelopes(redEnvelopes);
												
												int source = userSendEnvelopesRequest.getSource();
												String code = userSendEnvelopesRequest.getCode();
												if(source==1){
													WxJsPayReq req=new WxJsPayReq();
													req.setCode(code);
													req.setPhone(phoneNumber);
													req.setUnitPrice(money);
													req.setProductName("红包打赏");
													req.setProductType(Const.REDBAG);
													req.setProductId(uuid);
													WxjsPayRes jssdPayRes=(WxjsPayRes)weiXinPayService.jSSDKPayInfo(req, request);
													return jssdPayRes;
												}else {
													WxAppPayReq wxAppPayReq = new WxAppPayReq();
													wxAppPayReq.setAmount(1);
													wxAppPayReq.setPhone(phoneNumber);
													wxAppPayReq.setProductId(uuid);
													wxAppPayReq.setProductName("红包打赏");
													wxAppPayReq.setProductType(producttypeRedbag);
													wxAppPayReq.setUnitPrice(money);
													WxAppPayRes appPay = (WxAppPayRes) weiXinPayService.appPay(wxAppPayReq,request);
													return appPay;
												}

											} else {
												// 数据哥错误
												userSendEnvelopesResponse
														.setCode("3");
												userSendEnvelopesResponse
														.setDes("数据格式错误！");
											}
										} else {
											// 数据错误
											userSendEnvelopesResponse
													.setCode("3");
											userSendEnvelopesResponse
													.setDes("数据格式错误！");
										}

									} else {
										// 你太调皮了
										// 数据错误
										userSendEnvelopesResponse.setCode("3");
										userSendEnvelopesResponse
												.setDes("亲你太调皮了，不能给自己发红包哦！");
									}
								} else {
									// 数据错误
									userSendEnvelopesResponse.setCode("3");
									userSendEnvelopesResponse.setDes("数据格式错误！");
								}

							} else {
								// 数据格式错误
								userSendEnvelopesResponse.setCode("3");
								userSendEnvelopesResponse.setDes("数据格式错误！！");
							}

						} else {
							// 数据哥错误
							userSendEnvelopesResponse.setCode("3");
							userSendEnvelopesResponse.setDes("数据格式错误！！！");
						}

					} else {
						// 重新登录
						userSendEnvelopesResponse.setCode("2");
						userSendEnvelopesResponse.setDes("重新登录");
					}

				} else {
					// 重新登录
					userSendEnvelopesResponse.setCode("2");
					userSendEnvelopesResponse.setDes("重新登录");
				}
			
			logger.info("返回："
					+ mapper.writeValueAsString(userSendEnvelopesResponse));
		} catch (Exception e) {
			e.printStackTrace();
			userSendEnvelopesResponse.setCode("0");
			userSendEnvelopesResponse.setDes("系统繁忙");
		}
		return userSendEnvelopesResponse;
	}

	// 红包记录接口
	@RequestMapping(value = "/redRecording", method = RequestMethod.POST)
	@ResponseBody
	public Object envelopesRecording(HttpServletRequest request,
			@RequestBody PageRequest pageRequest) {
		RedEnvelopesRecordingResponse redEnvelopesRecordingResponse = new RedEnvelopesRecordingResponse();

		try {
			logger.info("接收：" + mapper.writeValueAsString(pageRequest));

				CookieUser cookieUser = (CookieUser)request.getAttribute("cookieUser");
				if (cookieUser != null) {
					String phoneNumber = cookieUser.getPhoneNumber();

					int maxId = pageRequest.getMaxId();
					int sinceId = pageRequest.getSinceId();
					if (sinceId <= 0) {
						sinceId = 1;
					}
					if (maxId <= 0 || maxId < sinceId) {
						maxId = sinceId;
					}
					PagePhone pagePhone = new PagePhone();

					pagePhone.setPageIndex(sinceId - 1);
					pagePhone.setPageSize(maxId - sinceId + 1);
					pagePhone.setPhoneNum(phoneNumber);
					List<RedEnvelopes> list = redEnvelopesService
							.getRedListByPhone(pagePhone);
					if (list != null && list.size() > 0) {
						for (RedEnvelopes redEnvelopes : list) {
							String sendPhoneNum = redEnvelopes.getSendPhoneNum();
							
							if (sendPhoneNum.equals(phoneNumber)) {

								redEnvelopes.setSendPhoneNum("0");
							} else {
								redEnvelopes.setSendPhoneNum("1");
							}
							String redType = redEnvelopes.getRedType();
							if(redType!=null&&!redType.equals("")){
								if(redType.equals(PayTypeUtil.REDENVELPES_TTK)){
									redEnvelopes.setRedType(PayTypeUtil.REDENVELPESSTRING_TTK);
								}else if(redType.equals(PayTypeUtil.REDENVELPES_REWARD)){
									if(sendPhoneNum.equals(phoneNumber)){
										redEnvelopes.setRedType(PayTypeUtil.REDENVELPESSTRING_REWARD);
									}else {
										redEnvelopes.setRedType(PayTypeUtil.REDENVELPESSTRING_BEREWARD);

									}
								}else if(redType.equals(PayTypeUtil.REDENVELPES_REGISTER)){
									redEnvelopes.setRedType(PayTypeUtil.REDENVELPESSTRING_REGISTER);
								}else if(redType.equals(PayTypeUtil.REDENVELPES_SHARE)){
									redEnvelopes.setRedType(PayTypeUtil.REDENVELPESSTRING_SHARE);
								}else {
									redEnvelopes.setRedType(PayTypeUtil.REDENVELPESSTRING_TTK);
								}
								
							}else {
								redEnvelopes.setRedType(PayTypeUtil.REDENVELPESSTRING_TTK);
							}
							
						}

						redEnvelopesRecordingResponse.setRedEnvelopes(list);
						redEnvelopesRecordingResponse.setSinceId(sinceId);
						redEnvelopesRecordingResponse.setMaxId(sinceId
								+ list.size() - 1);
						redEnvelopesRecordingResponse.setRows(list.size());
					}

					redEnvelopesRecordingResponse.setCode("1");

				} else {
					// 重新登录
					redEnvelopesRecordingResponse.setCode("2");
					redEnvelopesRecordingResponse.setDes("重新登录");
				}
			
			logger.info("返回："
					+ mapper.writeValueAsString(redEnvelopesRecordingResponse));
		} catch (Exception e) {
			e.printStackTrace();
			redEnvelopesRecordingResponse.setCode("0");
			redEnvelopesRecordingResponse.setDes("系统繁忙");
		}
		return redEnvelopesRecordingResponse;
	}

	// 提现记录接口
	@RequestMapping(value = "/withdrawRecording", method = RequestMethod.POST)
	@ResponseBody
	public Object withdrawRecording(HttpServletRequest request,
			@RequestBody PageRequest pageRequest) {
		WithdawRecordinResponse withdawRecordinResponse = new WithdawRecordinResponse();

		try {
			
			logger.info("接收：" + mapper.writeValueAsString(pageRequest));

				CookieUser cookieUser = (CookieUser)request.getAttribute("cookieUser");
				if (cookieUser != null) {
					String phoneNumber = cookieUser.getPhoneNumber();
					if (phoneNumber != null) {
						int maxId = pageRequest.getMaxId();
						int sinceId = pageRequest.getSinceId();
						if (sinceId <= 0) {
							sinceId = 1;
						}
						if (maxId <= 0 || maxId < sinceId) {
							maxId = sinceId;
						}
						PagePhone pagePhone = new PagePhone();

						pagePhone.setPageIndex(sinceId - 1);
						pagePhone.setPageSize(maxId - sinceId + 1);
						pagePhone.setPhoneNum(phoneNumber);
						List<Withdraw> list = withdrawService
								.getWithdrawsByPhone(pagePhone);
						withdawRecordinResponse.setCode("1");
						withdawRecordinResponse.setMaxId(sinceId + list.size()
								- 1);
						withdawRecordinResponse.setSinceId(sinceId);
						withdawRecordinResponse.setRows(list.size());
						withdawRecordinResponse.setWithdraws(list);

					} else {
						// 重新登录
						withdawRecordinResponse.setCode("2");
						withdawRecordinResponse.setDes("重新登录");
					}
				} else {
					// 重新登录
					withdawRecordinResponse.setCode("2");
					withdawRecordinResponse.setDes("重新登录");
				}
			
			logger.info("返回："
					+ mapper.writeValueAsString(withdawRecordinResponse));
		} catch (Exception e) {
			e.printStackTrace();
			withdawRecordinResponse.setCode("0");
			withdawRecordinResponse.setDes("系统繁忙");
		}
		return withdawRecordinResponse;
	}
	// 提现记录接口
	@RequestMapping(value = "/withdrawList", method = RequestMethod.POST)
	@ResponseBody
	public Object withdrawList(HttpServletRequest request,
			@RequestBody PageRequest pageRequest) {
		WithdawRecordinResponse withdawRecordinResponse = new WithdawRecordinResponse();

		try {
			logger.info("接收：" + mapper.writeValueAsString(pageRequest));
				CookieUser cookieUser = (CookieUser)request.getAttribute("cookieUser");
				if (cookieUser != null) {
					String phoneNumber = cookieUser.getPhoneNumber();
					if (phoneNumber != null) {
						int maxId = pageRequest.getMaxId();
						int sinceId = pageRequest.getSinceId();
						if (sinceId <= 0) {
							sinceId = 1;
						}
						if (maxId <= 0 || maxId < sinceId) {
							maxId = sinceId;
						}
						PagePhone pagePhone = new PagePhone();

						pagePhone.setPageIndex(sinceId - 1);
						pagePhone.setPageSize(maxId - sinceId + 1);
						pagePhone.setPhoneNum(phoneNumber);
						
						WithdrawExample withdrawExample = new WithdrawExample();
						
						withdrawExample.setOrderByClause("createDate desc");
						withdrawExample.setPageIndex(sinceId - 1);
						withdrawExample.setPageSize(maxId - sinceId + 1);
						com.jieshuibao.model.db.WithdrawExample.Criteria createCriteria = withdrawExample.createCriteria();
						createCriteria.andPhoneNumEqualTo(phoneNumber);
						List<Withdraw> withdrawList = withdrawService.getPageWithdraw(withdrawExample);
						if(withdrawList!=null){
							for (Withdraw withdraw : withdrawList) {
								if(withdraw!=null){
									String status = withdraw.getStatus();
									if(status!=null&&!status.equals("")){
										if(status.equals("0")){
											withdraw.setReason("提现成功");
										}else if(status.equals("1")){
											withdraw.setReason("提现审核中");
										}else if(status.equals("5")){
											withdraw.setStatus("2");
											withdraw.setReason("提现失败，金额已退回钱包");
										}else if(status.equals("6")){
											withdraw.setStatus("2");
											withdraw.setReason("审核未通过，请联系管理员");
										}else if(status.equals("7")){
											withdraw.setStatus("2");
											withdraw.setReason("姓名与微信实名不一致导致提现失败，金额已退回钱包");
										}else {
											withdraw.setStatus("2");
											withdraw.setReason("提现错误，请联系管理员");
										}
									}
									
								}
								
							}
						}
						
						
						
						withdawRecordinResponse.setCode("1");
						withdawRecordinResponse.setMaxId(sinceId + withdrawList.size()
								- 1);
						withdawRecordinResponse.setSinceId(sinceId);
						withdawRecordinResponse.setRows(withdrawList.size());
						withdawRecordinResponse.setWithdraws(withdrawList);

					} else {
						// 重新登录
						withdawRecordinResponse.setCode("2");
						withdawRecordinResponse.setDes("重新登录");
					}
				} else {
					// 重新登录
					withdawRecordinResponse.setCode("2");
					withdawRecordinResponse.setDes("重新登录");
				}
			logger.info("返回："
					+ mapper.writeValueAsString(withdawRecordinResponse));
		} catch (Exception e) {
			e.printStackTrace();
			withdawRecordinResponse.setCode("0");
			withdawRecordinResponse.setDes("系统繁忙");
		}
		return withdawRecordinResponse;
	}

}
